<?php

/**
 * Extraction du code postal et de l'adresse
 * 
 * @param string $string
 * @return array
 */
function extractAdress($string){
    $word = explode(' ', $string);
    $cp = $word[0];
    $adrs = '';
    foreach($word as $w){
        if($w == $cp) continue;
        $adrs .= $w .' ';
    }
    $array = array(
        'cp' => $cp,
        'adresse' => rtrim($adrs),
    );
    return $array;
}

/**
 * 
 * @param type $string
 * @return boolean
 */
function isUrl($string){
    if(strlen($string) > 3 && filter_var($string, FILTER_VALIDATE_URL)){
        return true;
    }else{
        return false;
    }
}

/**
 * 
 * @param type $node
 * @return type
 */
function get_inner_html( $node ) { 
    $innerHTML= ''; 
    $children = $node->childNodes; 
    foreach ($children as $child) { 
        $innerHTML .= $child->ownerDocument->saveXML( $child ); 
    } 

    return $innerHTML; 
} 